﻿Public Class FrmPrintTour
    Public objDS As DataSet
    Public dtNgayBD As DateTime
    Public dtNgayKT As DateTime

    Private Sub FrmPrintTour_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dt As DataTable = New DataTable()
        dt.Columns.Add("STT")
        dt.Columns.Add("TenTour")
        dt.Columns.Add("DonGia")
        dt.Columns.Add("NgayBD")
        dt.Columns.Add("NgayKT")

        For i As Integer = 0 To objDS.Tables(0).Rows.Count - 1
            dt.Rows.Add((i + 1).ToString(), objDS.Tables(0).Rows(i)("TenTour").ToString(), objDS.Tables(0).Rows(i)("DonGia").ToString(), String.Format("{0:dd/MM/yyyy}", DateTime.Parse(objDS.Tables(0).Rows(i)("NgayBD").ToString())), String.Format("{0:dd/MM/yyyy}", DateTime.Parse(objDS.Tables(0).Rows(i)("NgayKT").ToString())))
        Next

        Dim rpt As RptDSTour = New RptDSTour()
        rpt.DataDefinition.FormulaFields("TuNgay").Text = "'" + String.Format("{0:dd/MM/yyyy}", dtNgayBD) + "'"
        rpt.DataDefinition.FormulaFields("DenNgay").Text = "'" + String.Format("{0:dd/MM/yyyy}", dtNgayKT) + "'"
        rpt.SetDataSource(dt)
        CrystalReportViewer1.ReportSource = rpt
    End Sub
End Class